package com.wordplat.quickstart.xutils.common;

import com.wordplat.quickstart.xutils.common.task.AbsTask;

/**
 * Created by wyouflf on 15/6/11.
 * 任务管理接口
 *
 * @since 2021-05-09
 */
public interface TaskController {
    /**
     * autoPost
     *
     * @param runnable
     */
    void autoPost(Runnable runnable);

    /**
     * post
     *
     * @param runnable
     */
    void post(Runnable runnable);

    /**
     * postDelayed
     *
     * @param runnable
     * @param delayMillis
     */
    void postDelayed(Runnable runnable, long delayMillis);

    /**
     * run
     *
     * @param runnable
     */
    void run(Runnable runnable);

    /**
     * removeCallbacks
     *
     * @param runnable
     */
    void removeCallbacks(Runnable runnable);

    /**
     * start
     *
     * @param task
     * @param <T>
     * @return AbsTask
     */
    <T> AbsTask<T> start(AbsTask<T> task);

    /**
     * startSync
     *
     * @param task
     * @param <T>
     * @return T
     * @throws Throwable
     */
    <T> T startSync(AbsTask<T> task) throws Throwable;

    /**
     * startTasks
     *
     * @param groupCallback
     * @param tasks
     * @param <T>
     * @return Callback.Cancelable
     */
    <T extends AbsTask<?>> Callback.Cancelable startTasks(Callback.GroupCallback<T> groupCallback, T... tasks);
}
